{extend name='base' /}
{block name='content'}
<body>
<div class="x-body">
    <form class="layui-form" id="AddData">
        <div class="layui-form-item">
            <input type="hidden" name="id" value="{$adminData['admin_id']}">
            <label for="username" class="layui-form-label">
                <span class="x-red">*</span>登录名
            </label>
            <div class="layui-input-inline">
                <input type="text" id="username" name="username" required="" lay-verify="required"
                       autocomplete="off" value="{$adminData.username}" class="layui-input" readonly>
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>将会成为您唯一的登入名
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label"><span class="x-red">*</span>角色</label>
            <div class="layui-input-block">
                {volist name='roleData' id='vo'}
                <input type="radio" name="role" lay-skin="primary" title="{$vo.role_name}" value="{$vo.role_id}" {if $adminData['role_id']==$vo['role_id']}checked{/if}>
                {/volist}
            </div>
        </div>
        <div class="layui-form-item">
            <label for="L_pass" class="layui-form-label">
                密码
            </label>
            <div class="layui-input-inline">
                <input type="password" id="L_pass" name="pass" required="" lay-verify="pass"
                       autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                6到16个字符
            </div>
        </div>
        <div class="layui-form-item">
            <label for="L_repass" class="layui-form-label">
               确认密码
            </label>
            <div class="layui-input-inline">
                <input type="password" id="L_repass" name="repass" required="" lay-verify="repass"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="L_repass" class="layui-form-label">
            </label>
            <a  class="layui-btn" href="javascript:adminAdd();" >
                保存
            </a>
        </div>
    </form>
</div>
<script>
function adminAdd() {
   $.ajax({
       url:"{:url('role/adminedit')}",
       type:'post',
       dataType:'json',
       data:$('#AddData').serialize(),
       success:function (res) {
           if (res.code==1){
               layer.msg(res.message,{icon:6});
               setTimeout(function () {
                   x_admin_close();
                   window.parent.location.reload();
               },1000)
           } else{
               layer.msg(res.message,{icon:2,time:1000})
           }
       },
       error:function () {
           layer.msg('出错了，请稍后再试！',{icon:5,time:1000})
       }
   })
}
</script>

</body>
{/block}